<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--点击按钮时调用方法-->
<input type="button" value="按钮" onclick="f1()">
<script>
    //1.无参无返回值
    function f1() {
        console.log("f1")
    }
    //调用方法
    f1();

    //2.无参有返回值
    function f2() {
        return "这是返回值!";
    }
    let info = f2();
    console.log(info);

    //3.有参无返回值
    function f3(name, age) {
        console.log(name + ":" + age);
    }
    f3("刘德华", 17);

    //4.有参有返回值
    function f4(x,y) {
        return x*y;
    }
    let result = f4(8,8);
    console.log(result);

    //第二种定义方法的方式
    let f5 = function (name,age) {
        console.log(name + ":" + age)
    }
    f5("张学友",33);

    //第三种定义方法的方式
    let f6 = new Function("name","age","console.log(name + ':' + age)");
    f6("周润发",40);
</script>
</body>
</html>